export function ppd() {
	var num = 0.85 + (Math.random() / 20)
	return num.toFixed(3)
}

export const data01 = [
	[{
		value: "法院公告",
		width: 202
	}, {
		value: "涉案信息",
		width: 202
	}, {
		value: "案件流程",
		width: 202
	}],
	[{
		value: "0条",
		width: 202
	}, {
		value: "0条",
		width: 202
	}, {
		value: "0条",
		width: 202
	}],
]

export const data02 = [
	[{
		value: "执行公告",
		width: 202
	}, {
		value: "限制高消费",
		width: 202
	}, {
		value: "曝光台",
		width: 202
	}],
	[{
		value: "0条",
		width: 202
	}, {
		value: "0条",
		width: 202
	}, {
		value: "0条",
		width: 202
	}],
]

export function disData(data) {
	data01[1][0].value = getAJnum(data.civil)
	data01[1][1].value = getAJnum(data.criminal)
	data01[1][2].value = getAJnum(data.administrative)

	data02[1][0].value = getAJnum(data.implement)
	data02[1][1].value = getAJnum(data.bankrupt)
	data02[1][2].value = getAJnum(data.preservation)

	// data03[1][0].value = data.count.count_total
	// data03[1][1].value = data.count.count_jie_total
	// data03[1][2].value = data.count.count_wei_tota
	// data03[1][3].value = data.count.count_yuangao
	// data04[1][0].value = data.count.count_jie_yuangao
	// data04[1][1].value = data.count.count_wei_yuangao
	// data04[1][2].value = data.count.count_beigao
	// data04[1][3].value = data.count.count_jie_beigao
	// data05[1][0].value = data.count.count_wei_beigao
	// data05[1][1].value = data.count.count_other
	// data05[1][2].value = data.count.count_jie_other
	// data05[1][3].value = data.count.count_wei_other
	// data06[1][0].value = data.count.money_beigao
	// data06[1][1].value = data.count.money_jie_beigao
	// data06[1][2].value = data.count.money_jie_total
	// data06[1][3].value = data.count.money_wei_total
	// data07[1][0].value = data.count.money_wei_percent
	// data07[1][1].value = data.count.money_yuangao
	// data07[1][2].value = data.count.money_jie_yuangao
	// data07[1][3].value = data.count.money_wei_yuangao
	// data08[1][0].value = data.count.money_total
}

export function getAJnum(data) {
	if ('cases' in data) {
		return data.cases.length + '条'
	}
	return '未命中（0条）'
}

export function disposeCasesTree(data) {
	const names = {
		'civil': '民事案件',
		'criminal': '刑事案件',
		'administrative': '行政案件',
		'preservation': '非诉保全审查',
		'implement': '执行案件',
		// 'jurisdict': '管辖案件',
		// 'compensate': '赔偿案件',
		'bankrupt': '破产清算案件',
	};
	const chill = [];
	for (let key in data) {
		if (data[key].length > 0) {
			var children = []
			data[key].forEach(element => {
				if ('next' in element) {
					children.push({
						name: element.c_ah,
						children: deep(element.next)
					})
				} else {
					children.push({
						name: element.c_ah
					})
				}
			})
			chill.push({
				name: names[key],
				children
			})
		}
	}
	return {
		name: '案件',
		children: chill
	}
}

function deep(data) {
	if ('next' in data) {
		return [{
			name: data.c_ah,
			children: deep(data.next)
		}]
	} else {
		return [{
			name: data.c_ah
		}]
	}
}

